home *** CD-ROM | disk | FTP | other *** search
- #pragma once
-
- #include "LLPtrLib.h"
- #include "MenuLib.h"
- #include "TaskLib.h"
- #include "TimeLib.h"
-
- /* data about an object (usually a pointer or handle to the object)
- that can receive events */
- typedef void *EventObjectType;
- typedef long EventIDType;
-
- /* functions to execute for events */
- typedef struct {
-
- /* handlers called only for the focus object */
- struct {
- void (*idle)(EventObjectType object);
- void (*keydown)(EventObjectType object, EventRecord *event);
- Boolean (*menu)(EventObjectType object, const MenuPickType *pick);
- void (*adjustmenu)(EventObjectType object);
- } focusObject;
-
- /* handlers called for objects in the focus window */
- struct {
- void (*prefilter)(EventObjectType object, EventRecord *event);
- void (*postfilter)(EventObjectType object, EventRecord *event);
- void (*focus)(EventObjectType object, Boolean focus);
- void (*selectall)(EventObjectType object);
- void (*clicked)(EventObjectType object, EventObjectType clickedObject, EventIDType clickedID);
- Boolean (*within)(EventObjectType object, Point where);
- Boolean (*mousedown)(EventObjectType object, EventRecord *event);
- Boolean (*adjustcursor)(EventObjectType object, Point where, RgnHandle cursor);
- TicksType (*adjustsleep)(EventObjectType object);
- } focusWindow;
-
- /* handlers called for all objects in a window */
- struct {
- void (*resize)(EventObjectType object, short dh, short dv);
- void (*grow)(EventObjectType object, Rect *size);
- void (*zoom)(EventObjectType object, short *width, short *height);
- void (*update)(EventObjectType object);
- void (*activate)(EventObjectType object, Boolean activate);
- void (*close)(EventObjectType object);
- } window;
-
- /* handlers called for each object type */
- struct {
- Boolean (*menu)(const MenuPickType *pick);
- void (*adjustmenu)(void);
- void (*memorylow)(void);
- void (*suspend)(void);
- void (*resume)(void);
- } objectType;
-
- } EventTableType;
-
- /* structure of an object that responds to events */
- typedef struct EventType {
- LLType next; /* next object in list */
- EventIDType id; /* object's id */
- EventObjectType object; /* the object */
- const EventTableType *table; /* event handlers */
- } EventType;
-
- /* globals */
- extern Boolean gInBackground; /* true if application is in the background */
-
- /* event table */
- void EventTableRegister(const EventTableType *table);
-
- /* accessing the focus object and focus window */
- Boolean EventValid(EventType *event);
- void FocusSet(EventObjectType object);
- void FocusWindowSet(WindowPtr window);
- WindowPtr FocusWindow(void);
- EventType *FocusList(void);
- EventObjectType FocusObject(void);
- EventIDType FocusID(void);
- const EventTableType *FocusTable(void);
-
- /* executing events */
- void EventMenu(const MenuPickType *pick);
- void EventAdjustMenu(void);
- void EventFocus(EventType *focus, Boolean flag);
- void EventActivate(WindowPtr window, Boolean activate);
- void EventExecute(EventRecord *event);
- void EventOne(void);
- void EventLoop(void);
- void EventLoopMain(void);
-
- /* utilities */
- Boolean EventInBackground(void);
- Boolean EventInAppleEvent(void);
- void EventLoopExit(Boolean flag);
- void EventInteractWithUser(void);
- Boolean EventGet(short mask, EventRecord *event, TicksType sleep, RgnHandle cursor);
-
- /* event tasks */
- TaskHandle EventPreTaskInsert(TaskActionType action, void *data);
- TaskHandle EventPostTaskInsert(TaskActionType action, void *data);
- void EventPreTaskDelete(TaskHandle task);
- void EventPostTaskDelete(TaskHandle task);
- void EventPreTasksExecute(void);
- void EventPostTasksExecute(void);
-